package com.nuoniu.sibanyun.mapper.erp;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nuoniu.sibanyun.entity.erp.ErpInvoiceType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;

/**
 * <p>
 * 发票分类 Mapper 接口
 * </p>
 *
 * @author 小啊刚
 * @since 2021-02-05
 */
public interface ErpInvoiceTypeMapper extends BaseMapper<ErpInvoiceType> {

    @Select("select * from fab_invoice_type where account_id=#{accountId} and name=#{name}")
    ErpInvoiceType getByName(String name, Integer accountId);

    @Select("select * from fab_invoice_type where account_id=#{accountId} and code=#{code}")
    ErpInvoiceType getByCode(String code, Integer accountId);


    @Insert("INSERT INTO fab_invoice_type(`company_id`, `account_id`, `name`, `code`, `type`) SELECT #{companyId},#{accountId},name,code,type FROM fab_invoice_type WHERE company_id = 1 AND account_id = 0")
    void initDefErpInvoiceType(Integer companyId,Integer accountId);
}
